<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/2/20
 * Time: 10:50
 */

namespace app\admin\controller;


use think\Db;
use think\Request;
class Classes extends Base {
    /**
     * 列表展示
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(request()->isAjax()){
            extract(input());
            $NowPage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('grade_class')->alias('a')
                ->join('up_school us','us.school_id =a.gs_school_id','left')
                ->join('up_grade ug','ug.grade_id = a.gs_grade_id','left')
                ->count();// 获取总条数
            $lists = Db::name('grade_class')->alias('a')
                ->page($NowPage,$limits)
                ->join('up_school us','us.school_id =a.gs_school_id','left')
                ->join('up_grade ug','ug.grade_id = a.gs_grade_id','left')
                ->field('a.*,us.school_name,ug.grade_name')
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
}